<template>
  <div class="button-buy">
    <a class="btn" v-if="currentValue == 0" href="javascript:;" @click="buy">Buy</a>
    <count v-else v-model="currentValue"></count>
  </div>
</template>

<script>
import Count from 'components/common/Count'

export default {
  name: 'ButtonBuy',

  components: {
    Count
  },

  props: {
    value: {
      type: Number,
      default: 0
    }
  },

  data() {
    return {
      currentValue: this.value
    }
  },

  watch: {
    value(val) {
      this.currentValue = val
    },

    currentValue(val) {
      this.$emit('input', val)
    }
  },

  methods: {
    buy() {
      this.currentValue++
    }
  }
}
</script>

<style lang="less" scoped>
.button-buy {
  .btn {
    display: inline-block;
    min-width: 60px;
    height: 32px;
    padding: 0 10px;
    border-radius: 500px;
    line-height: 32px;
    text-align: center;
    background-color: #41B883;
    color: #fff;
  }
}
</style>
